﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using WorkflowDesigner.Workflow.Item;

namespace WorkflowDesigner.Workflow.Area
{
    public partial class ToolBox : UserControl
    {
        public ToolBox()
        {
            InitializeComponent();
            LayoutRoot.Background = new SolidColorBrush(Color.FromArgb(255, 245, 245, 245));
            OnInit();
        }

        private void OnInit()
        {
            TextBlock text = null;

            FlowStart objStartNode = new FlowStart();
            objStartNode.IsUseForToolBox = true;
            objStartNode.Margin = new Thickness(0.0, 20.0, 0.0, 0.0);
            LayoutRoot.Children.Add(objStartNode);
            text = new TextBlock();
            text.Text = "开始";
            text.FontSize = 12.0;
            text.HorizontalAlignment = HorizontalAlignment.Center;
            text.Margin = new Thickness(0.0, 0.0, 0.0, 10.0);
            LayoutRoot.Children.Add(text);

            FlowEnd objEndNode = new FlowEnd();
            objEndNode.IsUseForToolBox = true;
            objEndNode.Margin = new Thickness(0.0, 10.0, 0.0, 0.0);
            LayoutRoot.Children.Add(objEndNode);
            text = new TextBlock();
            text.Text = "结束";
            text.FontSize = 12.0;
            text.HorizontalAlignment = HorizontalAlignment.Center;
            text.Margin = new Thickness(0.0, 0.0, 0.0, 10.0);
            LayoutRoot.Children.Add(text);

            FlowNormal objNormalNode = new FlowNormal();
            objNormalNode.IsUseForToolBox = true;
            objNormalNode.Margin = new Thickness(0.0, 10.0, 0.0, 0.0);
            LayoutRoot.Children.Add(objNormalNode);
            text = new TextBlock();
            text.Text = "流程";
            text.FontSize = 12.0;
            text.HorizontalAlignment = HorizontalAlignment.Center;
            text.Margin = new Thickness(0.0, 0.0, 0.0, 10.0);
            LayoutRoot.Children.Add(text);

            FlowCondition objCondition = new FlowCondition();
            objCondition.IsUseForToolBox = true;
            objCondition.Margin = new Thickness(0.0, 10.0, 0.0, 0.0);
            LayoutRoot.Children.Add(objCondition);
            text = new TextBlock();
            text.Text = "判定";
            text.FontSize = 12.0;
            text.HorizontalAlignment = HorizontalAlignment.Center;
            text.Margin = new Thickness(0.0, 0.0, 0.0, 10.0);
            LayoutRoot.Children.Add(text);
        }

        public WorkflowBase FindItemMouseOver()
        {
            WorkflowBase objFind = null;
            foreach (UIElement elem in LayoutRoot.Children)
            {
                WorkflowBase item = elem as WorkflowBase;
                if (item != null)
                {
                    if (item.IsMouseOver)
                    {
                        objFind = item;
                        break;
                    }
                }
            }
            return objFind;
        }
    }
}
